package com.dream.refreshconfig;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @description: 自动装配类
 * @author: BrightLight
 * @create: 2025-05-28 22:06:39
 **/
@Configuration
@ConditionalOnProperty(prefix = "refresh.config", name = "enabled", havingValue = "true")
public class RefreshConfigConfiguration {

    protected final Log logger = LogFactory.getLog(RefreshConfigConfiguration.class);

    {
        logger.info("=============================================");
        logger.info("加载自动刷新配置文件配置类");
        logger.info("=============================================");
    }

    @Bean
    @ConditionalOnClass(name = "org.springframework.cloud.context.refresh.ContextRefresher")
    public ConfigFileChangeListener listener() {
        return new ConfigFileChangeListener();
    }

}
